/*****************************************************************************
*        描述 :
*             文件描述
*        CLR版本:            3.5
*        创建者 :            蒋 光
*        个人域名:           jiangguang.net.cn
*        命名空间名称:       ECP.Model
*        文件名:             BasePermissionEntity.cs
*        创建系统时间:       2012/11/2 19:07:03
*        创建年份:           2012
*
/*****************************************************************************/

namespace ECP.Model
{
    using System;
    using System.Data;
    using ECP.Utilities;

    [Serializable]
    public class BasePermissionEntity
    {
        private bool allowDelete;
        private bool allowEdit;
        private string code;
        private string createDate;
        private string createUserID;
        private string description;
        private bool enabled;
        private string fullName;
        private string id;
        private bool isScope;
        private string lastCall;
        private string modifyDate;
        private string modifyUserID;
        private string parentID;
        private string sortCode;

        public BasePermissionEntity()
        {
            this.id = string.Empty;
            this.parentID = string.Empty;
            this.code = string.Empty;
            this.fullName = string.Empty;
            this.allowEdit = true;
            this.allowDelete = true;
            this.lastCall = string.Empty;
            this.description = string.Empty;
            this.sortCode = string.Empty;
            this.createUserID = string.Empty;
            this.createDate = string.Empty;
            this.modifyUserID = string.Empty;
            this.modifyDate = string.Empty;
        }

        public BasePermissionEntity(DataRow dataRow)
        {
            this.id = string.Empty;
            this.parentID = string.Empty;
            this.code = string.Empty;
            this.fullName = string.Empty;
            this.allowEdit = true;
            this.allowDelete = true;
            this.lastCall = string.Empty;
            this.description = string.Empty;
            this.sortCode = string.Empty;
            this.createUserID = string.Empty;
            this.createDate = string.Empty;
            this.modifyUserID = string.Empty;
            this.modifyDate = string.Empty;
            this.GetFrom(dataRow);
        }

        public BasePermissionEntity(DataTable dataTable)
        {
            this.id = string.Empty;
            this.parentID = string.Empty;
            this.code = string.Empty;
            this.fullName = string.Empty;
            this.allowEdit = true;
            this.allowDelete = true;
            this.lastCall = string.Empty;
            this.description = string.Empty;
            this.sortCode = string.Empty;
            this.createUserID = string.Empty;
            this.createDate = string.Empty;
            this.modifyUserID = string.Empty;
            this.modifyDate = string.Empty;
            foreach (DataRow row in dataTable.Rows)
            {
                this.GetFrom(row);
                break;
            }
        }

        public BasePermissionEntity GetFrom(DataRow dataRow)
        {
            this.ID = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldID]);
            this.ParentID = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldParentID]);
            this.Code = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldCode]);
            this.FullName = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldFullName]);
            this.IsScope = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BasePermissionTable.FieldIsScope]);
            this.Enabled = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BasePermissionTable.FieldEnabled]);
            this.AllowEdit = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BasePermissionTable.FieldAllowEdit]);
            this.AllowDelete = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BasePermissionTable.FieldAllowDelete]);
            this.LastCall = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldLastCall]);
            this.SortCode = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldSortCode]);
            this.Description = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldDescription]);
            this.CreateUserID = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldCreateUserID]);
            this.CreateDate = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldCreateDate]);
            this.ModifyUserID = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldModifyUserID]);
            this.ModifyDate = BaseBusinessLogic.ConvertToString(dataRow[BasePermissionTable.FieldModifyDate]);
            return this;
        }

        public BasePermissionEntity GetFrom(DataTable dataTable)
        {
            foreach (DataRow row in dataTable.Rows)
            {
                this.GetFrom(row);
                break;
            }
            return this;
        }

        public bool AllowDelete
        {
            get
            {
                return this.allowDelete;
            }
            set
            {
                this.allowDelete = value;
            }
        }

        public bool AllowEdit
        {
            get
            {
                return this.allowEdit;
            }
            set
            {
                this.allowEdit = value;
            }
        }

        public string Code
        {
            get
            {
                return this.code;
            }
            set
            {
                this.code = value;
            }
        }

        public string CreateDate
        {
            get
            {
                return this.createDate;
            }
            set
            {
                this.createDate = value;
            }
        }

        public string CreateUserID
        {
            get
            {
                return this.createUserID;
            }
            set
            {
                this.createUserID = value;
            }
        }

        public string Description
        {
            get
            {
                return this.description;
            }
            set
            {
                this.description = value;
            }
        }

        public bool Enabled
        {
            get
            {
                return this.enabled;
            }
            set
            {
                this.enabled = value;
            }
        }

        public string FullName
        {
            get
            {
                return this.fullName;
            }
            set
            {
                this.fullName = value;
            }
        }

        public string ID
        {
            get
            {
                return this.id;
            }
            set
            {
                this.id = value;
            }
        }

        public bool IsScope
        {
            get
            {
                return this.isScope;
            }
            set
            {
                this.isScope = value;
            }
        }

        public string LastCall
        {
            get
            {
                return this.lastCall;
            }
            set
            {
                this.lastCall = value;
            }
        }

        public string ModifyDate
        {
            get
            {
                return this.modifyDate;
            }
            set
            {
                this.modifyDate = value;
            }
        }

        public string ModifyUserID
        {
            get
            {
                return this.modifyUserID;
            }
            set
            {
                this.modifyUserID = value;
            }
        }

        public string ParentID
        {
            get
            {
                return this.parentID;
            }
            set
            {
                this.parentID = value;
            }
        }

        public string SortCode
        {
            get
            {
                return this.sortCode;
            }
            set
            {
                this.sortCode = value;
            }
        }
    }
}